#include <bits/stdc++.h>
using namespace std;
 
long long l[200005], r[200005], dis[200005];
//l[i]表示i点向左边走，且最后回到i点最多能得多少分
//r[i]表示i点向右走，且最后回到i点最多能得多少
//dis[i]表示,从1号桥开始，走到i号桥，最多能得多少分
//求l[i] - dis[i] + r[j] + dis[j]
 
int n;
long long a[200005];
 
long long cal(long long x) {
    return x % 2 ? x - 1 : x;
}
set <long long> s;
 
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i < n; i++) {
        cin >> a[i];
    }
 
    for (int i = 1; i < n - 1; i++) {
        if (a[i] > 1) {
            l[i] = l[i - 1] + cal(a[i]);
        }
    }
    for (int i = n - 2; i >= 0; i--) {
        if (a[i + 1] > 1) {
            r[i] = r[i + 1] + cal(a[i + 1]);
        }
    }
 
    dis[1] = cal(a[1] - 1) + 1;
    for (int i = 2; i < n; i++) {
        dis[i] = (dis[i - 1] + cal(a[i] - 1) + 1);
    }
 
    long long ans = l[0] + r[0];
    long long maxl = l[0];
    for (int i = 1; i < n; i++) {
        maxl = max(maxl, l[i] - dis[i]);
        ans = max(ans, r[i] + dis[i] + maxl);
    }
 
    cout << ans;
    return 0;
}